package com.atom.module.author.mapper;

import com.atom.module.author.pojo.entity.Author;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AuthorMapper {

    //通过id , 软删除
    @Update("""
                UPDATE tb_author
                SET deleted = 1 , version = version + 1
                WHERE id = #{id}
            """)
    Boolean deleteByPrimaryKey(Long id);

    //通过account , 软删除
    @Update("""
                UPDATE tb_author
                SET deleted = 1 , version = version + 1
                WHERE account = #{account}
            """)
    Boolean deleteByAccount(String account);

    //删除
    @Delete("DELETE FROM tb_author where deleted = 1")
    Integer delete();

    int insert(Author author);

    int insertSelective(Author record);

    int insertBatch(List<Author> authors);

    Author selectByPrimaryKey(Long id);

    Author selectByAccount(String account);

    List<Author> selectAll();

    int updateByPrimaryKeySelective(Author record);

    int updateByPrimaryKey(Author record);

}
